<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:65:"C:\wwwroot\xtgl\public/../application/admin\view\login\index.html";i:1670148044;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>管理后台</title>
    <link rel="stylesheet" href="/static/admin/js/layui/css/layui.css" media="all">
    <!--JS引用-->
    <script src="/static/admin/js/jquery.js"></script>
    <script src="/static/admin/js/layui/layui.js"></script>
    <script src="/static/admin/layAdmin/js/wk.js"></script><!--封装方法-->
    <link rel="stylesheet" href="/static/admin/layAdmin/src/style/admin.css" >
    <link rel="stylesheet" href="/static/admin/layAdmin/src/style/login.css" />

    <script>
        /*保证登录页面是顶级页面*/
        if(window.top!==window.self){window.top.location=window.location};
    </script>
</head>
<body layadmin-themealias="default">



<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" >
    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>管理后台</h2>
            <p> </p>
        </div>
        <!--账号密码登录-->
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                        <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="" placeholder="图形验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img src="<?php echo url('checkVerify'); ?>" class="layadmin-user-login-codeimg" id="checkcodeimg">
                        </div>
                    </div>
                </div>
            </div>
            <!--<div class="layui-form-item" style="margin-bottom: 20px;">-->
                <!--<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">-->
                <!--<a lay-href="/user/forget" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>-->
            <!--</div>-->
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit id="LAY-user-login-submit" lay-filter="LAY-user-login-submit">登 入</button>
            </div>
        </div>
        <!--手机验证码登录-->
        <!--<div class="layadmin-user-login-box layadmin-user-login-body layui-form">-->

            <!--<div class="layui-form-item">-->
                <!--<label class="layadmin-user-login-icon layui-icon layui-icon-cellphone" for="LAY-user-login-cellphone"></label>-->
                <!--<input type="text" name="cellphone" id="LAY-user-login-cellphone" lay-verify="phone" placeholder="请输入手机号" class="layui-input">-->
            <!--</div>-->
            <!--<div class="layui-form-item">-->
                <!--<div class="layui-row">-->
                    <!--<div class="layui-col-xs7">-->
                        <!--<label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-smscode"></label>-->
                        <!--<input type="text" name="vercode" id="LAY-user-login-smscode" lay-verify="vercode" placeholder="短信验证码" class="layui-input">-->
                    <!--</div>-->
                    <!--<div class="layui-col-xs5">-->
                        <!--<div style="margin-left: 10px;">-->
                            <!--<button type="button" class="layui-btn layui-btn-primary layui-btn-fluid" id="LAY-user-forget-getsmscode">获取验证码</button>-->
                        <!--</div>-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
            <!--<div class="layui-form-item">-->
                <!--<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-forget-submit">登录</button>-->
            <!--</div>-->

        <!--</div>-->
    </div>

    <div class="layui-trans layadmin-user-login-footer">


    </div>

</div>
<script>

</script>
<script>
    layui.use('form', function(){
        var $ = layui.$
            ,setter = layui.setter
            ,form = layui.form;

        $('#checkcodeimg').click(function(){
            $(this).attr('src',"<?php echo url('checkVerify'); ?>?v="+Math.random() );
        });

        form.verify({
            vercode: function(value){
                if(!value){
                    return '验证码不能为空';
                }
            }
        });
        //监听提交
        form.on('submit(LAY-user-login-submit)', function(data){

            var username=$("#LAY-user-login-username").val();
            var password=$("#LAY-user-login-password").val();
            var checkcode=$("#LAY-user-login-vercode").val();

            var data={'username':username,'password':password,'checkcode':checkcode};

            $.ajax({
                url:"<?php echo url('Login/login'); ?>",
                type:'post',
                data:data,
                //dataType:"html",
                success:function(e){

                    if(e.code==1){
                        layer.msg(e.msg,{icon:1,time:1000,shade:0.2},function() {
                            window.location.href=e.data;
                        });
                    } else {
                        wk.success(e.msg,'','',2);
                    }
                },
                error:function(e){
                    layer.alert("登录失败！")
                },

            });


            return false;
        });

		//回车键登录
        $(document).keydown(function (event) {
            if (event.keyCode == 13) {
                $("#LAY-user-login-submit").trigger("click");
            }
        });

        //获取验证码
        $('#LAY-user-forget-getsmscode').on('click', function(){
            //发送短信验证码
            sendAuthCode({
                elem: '#LAY-user-forget-getsmscode'
                ,elemPhone: '#LAY-user-login-cellphone'
                ,elemVercode: '#LAY-user-login-vercode'
//                ,ajax: {
//                    url: './json/user/sms.js' //实际使用请改成服务端真实接口
//                }
            });

        });

        var sendAuthCode = function(options){
            var DISABLED = 'layui-disabled';
            options = $.extend({
                seconds: 60
                ,elemPhone: '#LAY_phone'
                ,elemVercode: '#LAY_vercode'
            }, options);

            options.elemPhone = $(options.elemPhone);
            options.elemVercode = $(options.elemVercode);

            var elemPhone = options.elemPhone
                ,value = elemPhone.val();

            //if(seconds !== options.seconds || $(this).hasClass(DISABLED)) return;

            if(!/^1\d{10}$/.test(value)){
                elemPhone.focus();
                return layer.msg('请输入正确的手机号')
            };

            if(typeof options.ajax === 'object'){
                var success = options.ajax.success;
                delete options.ajax.success;
            }

            var seconds = options.seconds
                ,btn = $(options.elem)
                ,token = null
                ,timer, countDown = function(loop){
                seconds--;
                if(seconds < 0){
                    btn.removeClass(DISABLED).html('获取验证码');
                    seconds = options.seconds;
                    clearInterval(timer);
                } else {
                    btn.addClass(DISABLED).html(seconds + '秒后重获');
                }

                if(!loop){
                    timer = setInterval(function(){
                        countDown(true);
                    }, 1000);
                }
            };


            if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iOS|iPad|Backerry|WebOS|Symbian|Windows Phone|Phone)/i))) {
                var ostype = 2;//document.write("手机访问.");
            }else{
                var ostype = 1;//document.write("电脑访问.");
            }

            $.ajax({
                url:"<?php echo url('Login/ajaxSmsCode'); ?>",
                type:'post',
                data:{phone:value},
                success:function(data){
                    if(data.code==1){
                        layer.msg('验证码已发送至你的手机，请注意查收', {
                            icon: 1
                            ,shade: 0
                        });
                        options.elemVercode.focus();
                        countDown();
                        success && success(res);
                    }else{
                        layer.msg(data.msg);
                    }

                }

            });

        }

    });
</script>
</body>
</html>